package l.l.w.网易2018实习.牛牛找工作;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

/**
 * Created by llw on 2018/3/28/0028.
 */
public class Main1 {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[][] works = new int[N][2];
        int[] Ai = new int[M];
        for(int i = 0; i < N; ++i){
            works[i][0] = scanner.nextInt();
            works[i][1] = scanner.nextInt();
        }
        for(int j = 0; j < M; ++j){
            Ai[j] = scanner.nextInt();
        }

        int[] result = new Main1().getResult(N,M,works,Ai);
        for(int i = 0; i < M; ++i){
            System.out.println(result[i]);
        }
    }

    private int[] getResult(int n, int m, int[][] works, int[] ai) {
        Arrays.sort(works, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[0] - o2[0];
            }
        });
        int[] result = new int[m];
        for(int i = 0; i<m; ++i){
            int max = 0;
            for(int j = 0; j < n; ++j){
                if(works[j][0] > ai[i])break;
                if(works[j][1] > max) max = works[j][1];
            }
            result[i] = max;
        }
        return result;
    }
}
